<template>
	<view class="content">
		<v-tabs v-model="menuIndex" :tabs="['全部','待核销','已完成']" bgColor="transparent" activeColor="#f08229"
			lineColor="#f08229" color="#00000" lineHeight='5rpx' @change="changeMenu()" class="vtabs" lineScale="0.3"
			paddingItem="0 50rpx"></v-tabs>
		<scroll-view class="activityList"  scroll-y="true"  @scrolltolower="getMore()">
			<view class="activityItem" v-for="(item,index) in activity" :key="index">
				<image :src="item.order_goods[0].goods_image" class="activityCover"></image>
				<text class="activityTitle">{{item.order_goods[0].goods_name}}</text>
				<view class="liveTeacherBox">
					<text class="liveTeacherName">活动时间：</text>
				</view>
				<view class="liveTimeBox">
					<text
						class="liveTime">{{formatTime(item.order_goods[0].start_time)}}</text>
				</view>
				<text class="waitVerification" v-if="item.type==1">待核销</text>
				<text class="completed" v-else-if="item.type==2">已完成</text>
				<text class="expired" v-else-if="item.type==3">已过期</text>
				<text class="activityPrice"
					v-if="item.order_goods[0].goods_price>0">￥{{item.order_goods[0].goods_price}}</text>
				<text class="activityPrice" v-else>免费</text>
				<view class="infoBtn" @click="$navto.navto('/user/activity_info/activity_info',{id:item.id,status:item.verification_status})">查看详情
				</view>
				<!-- <view class="infoBtn1" v-else>查看详情</view> -->
				<!-- <view class="infoBtn" v-if="item.type==1">查看详情</view>
				<view class="infoBtn1" v-else>查看详情</view> -->
				<text class="line" v-if="index!=activity.length-1"></text>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		baseURL,
		basePath
	} from '@/config/app'
	export default {
		data() {
			return {
				menuIndex: 0,
				baseUrl: `https://cdn.zkjialan.com/img/course/`,
				activity: [],
				verification_status: '',
				page_no:1
			}
		},
		onShow() {
			this.getData();
		},
		methods: {
			getMore() {
				this.page_no++;
				this.$request.get(`shopapi/order/lists?type_status=virtual&type=4&verification_status=${this.verification_status}&page_no=${this.page_no}&page_size=10`).then(res => {
					console.log(res.data);
					this.activity.push(...res.data.data.lists);
				})
			},
			getData(){
				this.$request.get(`shopapi/order/lists?type_status=virtual&type=4&verification_status=${this.verification_status}&page_no=${this.page_no}&page_size=10`).then(res => {
					console.log(res.data);
					this.activity = res.data.data.lists;
				})
			},
			changeMenu(index) {
				console.log('当前选中的项：' + index)
				this.page_no=1;
				if (index == 0) {
					this.verification_status = '';
				} else if (index == 1) {
					this.verification_status = 0;
				} else if (index == 2) {
					this.verification_status = 1;
				}
				this.getData();
			},
			formatTime(str) {
				return str.split(' ')[0];
			}
		},
	}
</script>

<style lang="scss" scoped>
	.activityList {
		overflow-y: scroll;
		width: 674rpx;
		margin-left: 37rpx;
		margin-top: 65rpx;
		height: 85vh;

		.liveTimeBox {
			position: absolute;
			top: 81rpx;
			left: 320rpx;
			display: flex;

			.liveTimeIcon {
				width: 21rpx;
				height: 21rpx;
			}

			.liveTime {
				font-size: 19rpx;
				color: #8e8e8e;
			}
		}

		.liveTeacherBox {
			position: absolute;
			top: 47rpx;
			left: 320rpx;
			display: flex;

			.livePersonIcon {
				width: 21rpx;
				height: 20rpx;
			}

			.liveTeacherName {
				font-size: 19rpx;
				color: #8e8e8e;
				// margin-left: 15rpx;
			}
		}

		.activityItem {
			position: relative;
			width: 674rpx;
			margin-bottom: 45rpx;

			.infoBtn1 {
				position: absolute;
				width: 128rpx;
				height: 50rpx;
				border-radius: 25rpx;
				background-color: #f08329;
				top: 127rpx;
				right: 0rpx;
				font-size: 22rpx;
				color: #fff;
				line-height: 50rpx;
				text-align: center;
				font-family: 'ar';
			}

			.infoBtn {
				position: absolute;
				width: 128rpx;
				height: 50rpx;
				border-radius: 25rpx;
				background-color: #f08329;
				top: 127rpx;
				right: 0rpx;
				font-size: 22rpx;
				color: #fff;
				line-height: 50rpx;
				text-align: center;
				font-family: 'ar';
			}

			.waitVerification {
				position: absolute;
				color: #f08229;
				top: 0rpx;
				right: 0rpx;
				font-size: 25rpx;
				font-family: 'ar';
			}

			.completed {
				position: absolute;
				color: #141414;
				top: 0rpx;
				right: 0rpx;
				font-size: 25rpx;
				font-family: 'ar';
			}

			.expired {
				position: absolute;
				color: #8e8e8e;
				top: 0rpx;
				right: 0rpx;
				font-size: 25rpx;
				font-family: 'ar';
			}

			.activityPrice {
				position: absolute;
				color: #f08329;
				top: 140rpx;
				left: 320rpx;
				font-size: 28rpx;
				font-family: 'am';
			}

			.activityTitle {
				position: absolute;
				font-size: 27rpx;
				color: #141414;
				top: 0;
				left: 320rpx;
				font-family: 'am';
			}


			.activityCover {
				width: 271rpx;
				height: 177rpx;
				border-radius: 10rpx;
			}
		}
	}

	.line {
		width: 674rpx;
		height: 1rpx;
		background-color: #dcdcdc;
		margin-top: 70rpx;
	}

	/deep/.v-tabs__container {
		justify-content: space-between;
	}

	.vtabs {
		margin-top: 50rpx;
	}

	.content {
		position: fixed;
		width: 100%;
		height: 100%;
		overflow-y: scroll;
		overflow-x: hidden;
		background-color: #fff;
	}

	page {
		width: 100%;
		height: 100%;
		overflow-y: scroll;
		background-color: #fff !important;
		padding-bottom: 0 !important;
	}
</style>